package com.clqteam.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.clqteam.service.serachProductByInfoService;
import com.clqteam.serviceimpl.serachProductByInfoServiceImpl;

import net.sf.json.JSONObject;

public class serachProductByInfoController extends HttpServlet{
	
	serachProductByInfoService spb = new serachProductByInfoServiceImpl();
	
	    @Override
	    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	    	doPost(req, resp);
	    }
	    
	    
	    @Override
	    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	    	//设置字符集
	 		req.setCharacterEncoding("UTF8");
	 		resp.setCharacterEncoding("UTF8");
	 		String searType = req.getParameter("searType");
	 		String sertInfo = req.getParameter("sertInfo");
			int page = Integer.parseInt(req.getParameter("page"));
	 		int rows = Integer.parseInt(req.getParameter("rows"));
	 		 PrintWriter pw = resp.getWriter();
	    	 JSONObject js = spb.findProductByInfo(searType, sertInfo, page, rows);
	    	 pw.write(js.toString());
	    }

}
